package com.ssy.lingxi.member.merchant.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 会员注册资料 - 关联的下拉框的枚举值
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-08
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_config_label", indexes = {@Index(name = "ms_mc_member_config_label_config_id_idx", columnList = "member_config_id")})
public class MemberConfigLabelDO implements Serializable {
    private static final long serialVersionUID = -638134167962414490L;

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_config_label_seq")
    @SequenceGenerator(sequenceName="ms_mc_member_config_label_seq", name="member_config_label_seq",allocationSize = 1)
    private Long id;

    /**
     * 多对一双向关联会员注册资料
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "member_config_id")
    private MemberConfigDO memberConfig;

    /**
     * 枚举值(文本)
     */
    @Column(columnDefinition = "varchar(20)")
    private String labelValue;

    /**
     * 顺序
     */
    @Column
    private Integer labelOrder;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public MemberConfigDO getMemberConfig() {
        return memberConfig;
    }

    public void setMemberConfig(MemberConfigDO memberConfig) {
        this.memberConfig = memberConfig;
    }

    public String getLabelValue() {
        return labelValue;
    }

    public void setLabelValue(String labelValue) {
        this.labelValue = labelValue;
    }

    public Integer getLabelOrder() {
        return labelOrder;
    }

    public void setLabelOrder(Integer labelOrder) {
        this.labelOrder = labelOrder;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MemberConfigLabelDO that = (MemberConfigLabelDO) o;
        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return "MemberConfigItemDO{" +
                "id=" + id +
                ", value='" + labelValue + '\'' +
                ", order=" + labelOrder +
                '}';
    }
}
